package com.example.demo.endpoint;

import com.example.demo.entity.PositionEntity;
import com.example.demo.service.PositionService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("/recruit/position")
public class PositionEndpoint {

    @Autowired
    PositionService positionService;

    @ResponseBody
    @RequestMapping("/query/all")
    public List<PositionEntity> queryAll(){

        List<PositionEntity> positionList = positionService.queryListAll();

        return positionList;
    }


    @ResponseBody
    @RequestMapping("/query/byCondition")
    public List<PositionEntity> queryByCondition(@RequestBody(required = false) PositionEntity positionEntity){

       return positionService.queryByCondition(positionEntity);

    }

    @ResponseBody
    @RequestMapping("/update")
    public String updatePosition(@RequestBody(required = false) PositionEntity positionEntity){

         return positionService.updatePosition(positionEntity);
    }


    @ResponseBody
    @RequestMapping("/delete")
    public String deletePosition(@RequestParam(required = false) String[] ids){

        return positionService.deletePosition(ids);
    }



}
